﻿import mx.containers.Window;
import mx.managers.PopUpManager;

/**
 * @des 生成窗口
 * @param winTitle 窗口标题
 * @param winX x轴坐标
 * @param winY y轴坐标
 * @param winWidth 窗口宽度
 * @param winHeight 窗口高度
 * @param cPath 要加载的MC
 * @param hasCloseButton 是否有关闭按钮
 * @return 窗口对象
 */
function buildWindow(winTitle:String,
					 winX:Number,
					 winY:Number,
					 winWidth:Number,
					 winHeight:Number,
					 cPath:String,
					 hasCloseButton:Boolean) {
	// 创建窗口
	var win:MovieClip = PopUpManager.createPopUp(_root,
												 Window,
												 true,
												 {
													title: winTitle,
													_x: winX,
													_y: winY,
													_width: winWidth,
													_height: winHeight,
													contentPath: cPath,
													closeButton: hasCloseButton
												 },
												 false);
	
	// 创建侦听事件
	var listenerObject:Object = new Object();
	listenerObject.click = function() {
		win.deletePopUp();
	};
	
	// 注册侦听事件
	win.addEventListener("click", listenerObject);
	
	return win;
}